/**
 * 创建人:  @author huangpeng    
 * 创建时间:  2023年08月18日 12:17
 * 项目名称:  lemon-blog-cloud
 * 文件名称:  BlBlogOptionsController
 * 文件描述:  @Description: 博客相关操作controller
 * 公司名称:  柠檬
 *
 * All rights Reserved, Designed By 柠檬 
 * @Copyright: 2022-2023
 *
 */
package com.lemon.blog.web.controller;

import com.lemon.blog.web.domain.BlBlogOptions;
import com.lemon.blog.web.service.BlBlogOptionsService;
import com.lemon.common.core.utils.poi.ExcelUtil;
import com.lemon.common.core.web.controller.BaseController;
import com.lemon.common.core.web.domain.AjaxResult;
import com.lemon.common.core.web.page.TableDataInfo;
import com.lemon.common.log.annotation.Log;
import com.lemon.common.log.enums.BusinessType;
import com.lemon.common.security.annotation.RequiresPermissions;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 包名称：com.lemon.blog.web.controller
 * 类名称：BlBlogOptionsController
 * 类描述：博客相关操作controller
 * 创建人：@author huangpeng
 * 创建时间：2023年08月18日 12:17
 */
@Api("博客相关操作")
@RestController
@RequestMapping("/blogOptions")
public class BlBlogOptionsController extends BaseController {

    @Autowired
    private BlBlogOptionsService blBlogOptionsService;

    /**
     * 查询博客相关操作列表
     * @Title: list
     * @Description: 查询博客相关操作列表
     * @param blBlogOptions 博客相关操作
     * @return: TableDataInfo
     * @throws:
     * @author: lemon
     * @Date: 2023-08-18
     */
    @GetMapping("/list")
    public TableDataInfo list(BlBlogOptions blBlogOptions) {
        startPage();
        List<BlBlogOptions> list = blBlogOptionsService.selectBlBlogOptionsList(blBlogOptions);
        return getDataTable(list);
    }

    /**
     * 导出博客相关操作列表
     * @Title: export
     * @Description: 导出博客相关操作列表
     * @param response 客户端响应对象
     * @param blBlogOptions 博客相关操作
     * @return:
     * @throws:
     * @author: lemon
     * @Date: 2023-08-18
     */
    @RequiresPermissions("system:options:export")
    @Log(title = "博客相关操作", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BlBlogOptions blBlogOptions) {
        List<BlBlogOptions> list = blBlogOptionsService.selectBlBlogOptionsList(blBlogOptions);
        ExcelUtil<BlBlogOptions> util = new ExcelUtil<BlBlogOptions>(BlBlogOptions.class);
        util.exportExcel(response, list, "博客相关操作数据");
    }

    /**
     * 获取博客相关操作详细信息
     * @Title: getInfo
     * @Description: 获取博客相关操作详细信息
     * @param id 博客相关操作主键
     * @return: AjaxResult
     * @throws:
     * @author: lemon
     * @Date: 2023-08-18
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(blBlogOptionsService.selectByPrimaryKey(id));
    }

    /**
     * 新增或者更新博客相关操作
     * @Title: insertOrUpdate
     * @Description: 新增或者更新博客相关操作
     * @param blBlogOptions 博客相关操作
     * @return: AjaxResult
     * @throws:
     * @author: lemon
     * @Date: 2023-08-18
     */
    @Log(title = "博客相关操作", businessType = BusinessType.INSERT)
    @PostMapping("insertOrUpdate")
    public AjaxResult insertOrUpdate(@RequestBody BlBlogOptions blBlogOptions) {
        return AjaxResult.success(blBlogOptionsService.insertOrUpdate(blBlogOptions));
    }

    /**
     * 删除博客相关操作
     * @Title: remove
     * @Description: 删除博客相关操作
     * @param ids 需要删除的博客相关操作主键集合
     * @return: AjaxResult
     * @throws:
     * @author: lemon
     * @Date: 2023-08-18
     */
    @Log(title = "博客相关操作", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(blBlogOptionsService.deleteByBatch(ids));
    }
}
